/**
 * Created by yangfan on 2016/10/8.
 */
define(['config/appregister',"../../services/httpServices","i18n"],function(app,httpService,i18n) {
    var injector = angular.injector(["ng"]);
    var topCate = [];
    var secCate = [];
    var currentTcId=0;
    //发送请求 获取工程资料库资料分类数据
    var requestion = {
        type: "GET",
        param: "getTopCategory"
    };
    httpService.getTopCategory(requestion).success(function (response) {
        if (response.msg !== "success") {
            return
        }
        //  得到 一级分类 分类名
        topCate = response.data;
    }).error(function () {
        console.log("请求失败！");
    });
    //提供获取二级分类服务
        return {
            getSecCategory: function (type) {
                var index = 0;
                if (type == "nation") {
                    index = 0;
                } else if (type == "intern") {
                    index = 1;
                }
                currentTcId = topCate[index].tcId;
                var req2 = {
                    type: "GET",
                    tcId: currentTcId,
                    param: 'getSecondaryCategory'
                };

                httpService.getSecondCategory(req2).success(function (response) {
                    if (response.data) {
                        secCate = response.data;
                    }
                });
                return secCate;
            },
            topCate: topCate


        }
});